package yawning.mew.cat;

import yawning.mew.sim.SimulationAction;
import yawning.mew.sim.SimulationEventAction;
import yawning.mew.BuffsDebuffs.Debuff;

public class EventShatteringThrow extends SimulationEventAction {
	private CatModelSimState mState;
	double mCooldownExpireTime = 0.0;

	EventShatteringThrow(CatModelSimState state) {
		super(state.mSimUtil);
		mState = state;
	}

	@Override
	public double perform() {
		if (mCooldownExpireTime <= mState.mSimUtil.getSimTime() && mState.mModel.buffsDebuffs.isDebuff(Debuff.SHATTERINGTHROW)) {
			schedule(mState.mModel.shatteringThrowDebuffDuration);
			mState.mModel.calculateTargetArmor(mState.getFeralFFStacks(), true);
			mCooldownExpireTime = mState.mSimUtil.getSimTime() + mState.mModel.shatteringThrowCDDuration;
			return 0.0;
		}
		return SimulationAction.ACTION_FAIL;
	}

	@Override
	public void onExpire() {
		mState.mModel.calculateTargetArmor(mState.getFeralFFStacks(), false);
	}
}
